import request from '@/utils/request.js'
// 分类：获取疵点数据
export const defectGetListService = (params) =>
  request.get('/MES/search', { params })

// 获取厂房分类
export const GetPlantService = (params) =>
  request.get('factory/list', { params })
// 获取台号分类
export const GetMachineService = (params) =>
  request.get('/dev/list', { params })
//布号分类
export const GetClothService = (params) =>
  request.get('/MES/getClothCodeList', { params })

// 获取疵点下载
export const GetDefectExcelService = (params) =>
  request.get('/MES/download', { params })

// 分类：添加机械
export const machineAddService = ({ id, deviceCode }) =>
  request.post('/dev/add', { id, deviceCode })

// 获取机械列表
export const machineGetListService = (params) =>
  request.get('/RealTime/R_DeviceInfoList', { params })
// 获取车间列表
export const GetWorkShopService = (params) =>
  request.get('/workShop/list', { params })
// 搜索账号
// export const searchAccount = (params) =>
//   request.get('', {
//     params
//   })

//获取检测开关状态
export const getSwitchStatue = (params) => {
  request.get(`/MES/remote/get/switch/detection?&equipment_no=${params}`)
}

//远程图片上传设置
export const remoteSetImageReport = (params) => {
  console.log("remoteSetImageReport",params)
  request.post('/MES/remote/set/image/report',null,{
    params
  })
}

//远程检测开关
export const remoteSetSwitchDetection = (params) => {
  console.log("remoteSetSwitchDetection",params)
  request.post('/MES/remote/set/switch/detection',null,{
    params
  })
}


//获取远程图片上传数据
export const remoteGetImageReport = (params) =>
  request.get(`/MES/remote/get/image/report?&equipment_no=${params}`)

//获取相机参数
export const remoteGetParameters = (params) => {
  console.log('params', params)
  return request.get(`/MES/remote/get/camera/parameters?&equipment_no=${params}`)
}

//上传相机参数

export const remoteSetParameters = (params) => {
  console.log('remoteSetParameters', params)
  return request.post('/MES/remote/set/camera/parameters', null, {
    params // 这里改成以 `params` 作为 URL 查询参数
  })
}
export const remoteGetEquipmentNumList = (product_type) =>
  request.get('/MES/remote/get/equipmentNum/list',{ params: {product_type:product_type} })


// 获得已经授权账号数据
export const getAuthorizedAccount = (params) =>
  request.get('/user/list', {
    params
  })
//添加厂房
export const addFactoryBuilding = ({ factoryName }) =>
  request.post('/factory/add', {
    factoryName
  })
// 获得厂房列表
export const getFactory = () => request.get('/factory/list')
//删除厂房
export const deleteFactoryBuilding = ({ factoryId }) =>
  request.post('/factory/delete', {
    factoryId
  })
// 添加车间
export const addWorkShop = ({ name }) =>
  request.post('/workShop/add', {
    name
  })
//获取车间列表
export const getWorkShop = () => request.get('/workShop/list')
// 删除车间
export const deleteWorkShop = ({ id }) =>
  request.post('/workShop/delete', { id })
// 授权
export const authorizeFactory = ({ userName, factoryId, id }) =>
  request.post('/user/setPermission', { userName, factoryId, id })
// 删除账号授权
export const deleteAccount = ({ userName, factoryId, id }) =>
  request.post('/user/deletePermission', { userName, factoryId, id })
//获得疵点统计数据
export const getDefectData = (params) => request.get('/MES/count', { params })
//获得布匹情况
export const getClothCondition = (params) =>
  request.get('/MES/count', { params })

export const deleteDeviceCode = ({ deviceCode, id }) =>
  request.post('/dev/delete', { deviceCode, id })
// 获取机台列表
export const getDeviceCodeList = () => request.get('/dev/list')
// 获取四分制报表
export const getFourScoreList = (params) => request.get('/ClothSheetFourScore/search',{params})

//获取二维码显示数据
export const getQrCodeData = (params) =>
    request.get(`/dev/getDev`,{params})

//提交ota文件
export const OTAupload = (formData) =>
  request.post('/OTA/upload', formData,{
    headers: {
      'Content-Type': 'multipart/form-data'
    } })

//获取ota列表
export const getOTAlist = (product_type) =>
  request.get(`/OTA/getOTAList`, {
    params: {
      product_type
    }
  })

//更新ota设备
export const updateAllOTA = (params) => request.post('/OTA/updateAllOTA', {},{params})

//获取产品类型数组
export const getProductType = () => request.get(`/OTA/getProductType`)

//更新部分在线ota文件
export const updateOnlineOTA = (devices, params) =>
  request.post(`/OTA/updateOTA`, devices, { params })

//更新部分离线ota文件
export const updateOfflineOTA = (devices, params) =>
  request.post(`/MES/remote/set/equipmentNum/upgradeUponStartup`, devices, { params })

//删除ota文件
export const DeleteOTA = (OtaId) =>
  request.post(`/OTA/deleteOta?OtaId=${OtaId}`)

//修改ota文件
export const EditOTA = (params) =>
    request.post(`/OTA/editOta`,  params )

export const getProgress = (taskId) =>
    request.get((`/OTA/get/=${taskId}`))